<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>

<blockquote class="layui-elem-quote"><{$action}></blockquote>

<form class="layui-form layui-form-pane" method="post" action="<{$post_url}>" id="form_add_role">
	<input type="hidden" name="id" value="<{$news_info['id']|default:'0'}>" />
	<div class="layui-form-item">
		<label class="layui-form-label">标题</label>
		<div class="layui-input-block">
			<input type="text" name="title" value="<{$news_info.title|default:''}>" lay-verify="title" autocomplete="off" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">作者</label>
			<div class="layui-input-block">
				<input type="text" name="author" value="<{$news_info.author|default:''}>" lay-verify="required" autocomplete="off" class="layui-input">
			</div>
	</div>

	<div class="layui-form-item">

		<div class="layui-inline">
			<label class="layui-form-label">顶级分类</label>
			<div class="layui-input-block" style="width:500px;">
				<select id="top_category_id" name="top_category_id" lay-filter="category">
					<option value="0">请选择分类</option>
					<{foreach from=$top_category item=top_cate_item}>
					<option value="<{$top_cate_item.id}>" <{if $top_cate_item.id == $news_info.top_category_id|default:""}> selected <{/if}>><{$top_cate_item.name}></option>
					<{/foreach}>
				</select>
			</div>
		</div>

		<div class="layui-inline" id="category_id_box" <{if !isset($category)}>style="display: none;"<{/if}>>
			<label class="layui-form-label">二级分类</label>
			<div class="layui-input-block" style="width:500px;">
				<select id="category_id" name="category_id" >
					<{if isset($category)}>
						<{foreach from=$category item=item}>
						<option value="<{$item.id}>" <{if $item.id == $news_info.category_id|default:""}> selected <{/if}>><{$item.name}></option>
						<{/foreach}>
					<{else}>
					<option value="0" <{if 0 == $news_info.top_category_id|default:""}> selected <{/if}>>分类1</option>
					<option value="1" <{if 1 == $news_info.top_category_id|default:""}> selected <{/if}>>分类2</option>
					<{/if}>
					
				</select>
			</div>
		</div>

	</div>

	<!-- <div class="layui-form-item">
		<label class="layui-form-label">类型</label>
		<div class="layui-input-block">
			<select name="news_type" lay-filter="q_type" <{if $news_info.type|default:"" > 0}> disabled <{/if}>>
				<option value="0" <{if 0 == $news_info.type|default:""}> selected <{/if}>>资讯</option>
				<option value="1" <{if 1 == $news_info.type|default:""}> selected <{/if}>>帮助</option>
			</select>
		</div>
	</div> -->

	<div class="layui-form-item">
		<label class="layui-form-label">是否启用</label>
		<div class="layui-input-block">
				<{assign var="status" value=$news_info.status|default:"1"}>
				<input type="checkbox" <{if $status == 1}> checked <{/if}> name="status" lay-skin="switch" lay-filter="switchTest" value="1" >
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">排序</label>
			<div class="layui-input-block">
				<input type="text" name="sort" value="<{$news_info.sort|default:'0'}>" autocomplete="off" class="layui-input">
			</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<input type="hidden" id="token" value="<{'VIMG'|get_qiniu_token}>" />
		<label class="layui-form-label">封面图</label>
		<div class="layui-input-block" style="margin-top: 5px;">
			<div id="uploader2" class="upload_box" style="float:left; width:420px;">
				<div class="queueList">
					<div id="dndArea2" class="placeholder dndArea">
						<div id="filePicker2" class="filePicker"></div>
						<p>或将照片拖到这里，最多可上传<script>document.write(fileNumLimit);</script>张图片</p>
					</div>
				</div>
				<div class="statusBar" style="display:none;">
					<div class="progress">
						<span class="text">0%</span>
						<span class="percentage"></span>
					</div><div class="info"></div>
					<div class="btns">
						<div id="filePickerBut2" class="filePickerBut"></div><div class="uploadBtn">开始上传</div>
					</div>
				</div>
				<div class="upload_img_input" input_name='news_images'></div>
			</div>
			<{if isset($news_info['news_images']) AND $news_info['news_images'] != ''}>
				<div class="layui-inline" style="float:left;"><img src="<{$news_info['news_images']}>" style="max-height:175px;"/></div>
			<{/if}>
		</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">摘要</label>
		<div class="layui-input-block">
			<textarea name="paper" class="layui-textarea"><{$news_info.paper|default:""}></textarea>
		</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">内容</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="editor"><{$news_info.content|default:""}></textarea>
		</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">SEO Keyword</label>
		<div class="layui-input-block">
			<textarea name="seo_keyword" class="layui-textarea"><{$news_info.seo_keyword|default:""}></textarea>
		</div>
	</div>

	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">SEO Description</label>
		<div class="layui-input-block">
			<textarea name="seo_description" class="layui-textarea"><{$news_info.seo_description|default:""}></textarea>
		</div>
	</div>

	<div class="layui-input-block">
		<button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>


<{include file="public_html/footer.html"}>
<script type="text/javascript">
	layui.use(['form','jquery'], function(){
		var form = layui.form(),$ = layui.jquery;
		form.on('select(category)', function(data){
			var ii = layer.load();
			var category_id = $(data.elem).val();
			$("#category_id").html('<option value="">请选择二级分类</option>');  
			form.render('select');
			$.ajax({
				type: "POST",
				url: "/news/ignore_get_children_category",
				dataType:"json",
				data:{category_id:category_id},
				success: function(result){
					layer.close(ii);
					if(result.code == 1){
						$("#category_id_box").show();
						var html ='';
						$.each(result.category_list, function(i, obj) {
							html += '<option value="'+obj.id+'">'+obj.name+'</option>';
						});
						$("#category_id").append(html);
						form.render('select');
					}else{
						$("#category_id_box").hide();
					}
				}
			});
		});
	});
</script>